/**
 *
 * Copyright by Samuel Castro & Joaquim Fonseca, 2011
 * All Rights Reserved
 *
 * NOTES:
 * Please do not redistribute this plugin without my permission
 * Plugin made for private use only
 *
 */
package com.SySammy.SdBank;

import com.SySammy.SdBank.Prop.BankProperties;
import org.bukkit.ChatColor;

public class RepeatingTask implements Runnable {

    String s;
    sdB plugin;

    public RepeatingTask(String s, sdB plugin) {
        this.s = s;
        this.plugin = plugin;
    }

    @Override
    public void run() {
        try {
            if (plugin.getBank().getTimeLeft(s) >= 0) {
                plugin.getBank().setTimeLeft(s);
                if (plugin.getBank().getTimeLeft(s) >= 1440) {
                    plugin.getServer().getPlayer(s).sendMessage(ChatColor.DARK_AQUA + "Don't forget to pay your bank!!!");
                    plugin.getServer().getPlayer(s).sendMessage(ChatColor.RED + "DeadLine: " + ChatColor.GOLD + plugin.getBank().getTimeLeft(s) / 1440 + " Day(s)" + ChatColor.RED + " [Updated every: " + BankProperties.ScheduleRepTime + " hour(s)]");
                    return;
                } else {
                    plugin.getServer().getPlayer(s).sendMessage(ChatColor.DARK_AQUA + "Don't forget to pay your bank!!!");
                    plugin.getServer().getPlayer(s).sendMessage(ChatColor.RED + "DeadLine: " + ChatColor.GOLD + plugin.getBank().getTimeLeft(s) + " Hour(s)" + ChatColor.RED + " [Updated every: " + BankProperties.ScheduleRepTime + " hour(s)]");
                    return;
                }
            }
        } catch (Exception e) {
        }
    }
}
